/**
 */
package mymobile.mobileTest.impl;

import java.util.Collection;

import mymobile.mobileTest.Component;
import mymobile.mobileTest.MobileTestPackage;
import mymobile.mobileTest.Setting;
import mymobile.mobileTest.View;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>View</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mymobile.mobileTest.impl.ViewImpl#getViewName <em>View Name</em>}</li>
 *   <li>{@link mymobile.mobileTest.impl.ViewImpl#getViewSetting <em>View Setting</em>}</li>
 *   <li>{@link mymobile.mobileTest.impl.ViewImpl#getViewComponents <em>View Components</em>}</li>
 *   <li>{@link mymobile.mobileTest.impl.ViewImpl#getNextViews <em>Next Views</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ViewImpl extends EObjectImpl implements View {
	/**
	 * The default value of the '{@link #getViewName() <em>View Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getViewName()
	 * @generated
	 * @ordered
	 */
	protected static final String VIEW_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getViewName() <em>View Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getViewName()
	 * @generated
	 * @ordered
	 */
	protected String viewName = VIEW_NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getViewSetting() <em>View Setting</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getViewSetting()
	 * @generated
	 * @ordered
	 */
	protected Setting viewSetting;

	/**
	 * The cached value of the '{@link #getViewComponents() <em>View Components</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getViewComponents()
	 * @generated
	 * @ordered
	 */
	protected EList<Component> viewComponents;

	/**
	 * The cached value of the '{@link #getNextViews() <em>Next Views</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNextViews()
	 * @generated
	 * @ordered
	 */
	protected EList<View> nextViews;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ViewImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MobileTestPackage.Literals.VIEW;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getViewName() {
		return viewName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setViewName(String newViewName) {
		String oldViewName = viewName;
		viewName = newViewName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileTestPackage.VIEW__VIEW_NAME, oldViewName, viewName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Setting getViewSetting() {
		if (viewSetting != null && viewSetting.eIsProxy()) {
			InternalEObject oldViewSetting = (InternalEObject)viewSetting;
			viewSetting = (Setting)eResolveProxy(oldViewSetting);
			if (viewSetting != oldViewSetting) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MobileTestPackage.VIEW__VIEW_SETTING, oldViewSetting, viewSetting));
			}
		}
		return viewSetting;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Setting basicGetViewSetting() {
		return viewSetting;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setViewSetting(Setting newViewSetting) {
		Setting oldViewSetting = viewSetting;
		viewSetting = newViewSetting;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileTestPackage.VIEW__VIEW_SETTING, oldViewSetting, viewSetting));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Component> getViewComponents() {
		if (viewComponents == null) {
			viewComponents = new EObjectResolvingEList<Component>(Component.class, this, MobileTestPackage.VIEW__VIEW_COMPONENTS);
		}
		return viewComponents;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<View> getNextViews() {
		if (nextViews == null) {
			nextViews = new EObjectResolvingEList<View>(View.class, this, MobileTestPackage.VIEW__NEXT_VIEWS);
		}
		return nextViews;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MobileTestPackage.VIEW__VIEW_NAME:
				return getViewName();
			case MobileTestPackage.VIEW__VIEW_SETTING:
				if (resolve) return getViewSetting();
				return basicGetViewSetting();
			case MobileTestPackage.VIEW__VIEW_COMPONENTS:
				return getViewComponents();
			case MobileTestPackage.VIEW__NEXT_VIEWS:
				return getNextViews();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MobileTestPackage.VIEW__VIEW_NAME:
				setViewName((String)newValue);
				return;
			case MobileTestPackage.VIEW__VIEW_SETTING:
				setViewSetting((Setting)newValue);
				return;
			case MobileTestPackage.VIEW__VIEW_COMPONENTS:
				getViewComponents().clear();
				getViewComponents().addAll((Collection<? extends Component>)newValue);
				return;
			case MobileTestPackage.VIEW__NEXT_VIEWS:
				getNextViews().clear();
				getNextViews().addAll((Collection<? extends View>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MobileTestPackage.VIEW__VIEW_NAME:
				setViewName(VIEW_NAME_EDEFAULT);
				return;
			case MobileTestPackage.VIEW__VIEW_SETTING:
				setViewSetting((Setting)null);
				return;
			case MobileTestPackage.VIEW__VIEW_COMPONENTS:
				getViewComponents().clear();
				return;
			case MobileTestPackage.VIEW__NEXT_VIEWS:
				getNextViews().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MobileTestPackage.VIEW__VIEW_NAME:
				return VIEW_NAME_EDEFAULT == null ? viewName != null : !VIEW_NAME_EDEFAULT.equals(viewName);
			case MobileTestPackage.VIEW__VIEW_SETTING:
				return viewSetting != null;
			case MobileTestPackage.VIEW__VIEW_COMPONENTS:
				return viewComponents != null && !viewComponents.isEmpty();
			case MobileTestPackage.VIEW__NEXT_VIEWS:
				return nextViews != null && !nextViews.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (viewName: ");
		result.append(viewName);
		result.append(')');
		return result.toString();
	}

} //ViewImpl
